package com.sinosoft.controller.system;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.sinosoft.entity.DefCompany;
import com.sinosoft.service.system.ICompanyService;

@Controller
@RequestMapping("/system")
public class CompanyController {

	@Autowired
	private ICompanyService companyService;

	@RequestMapping("/company")
	public ModelAndView company(ModelAndView modelAndView) {
		modelAndView.setViewName("system/company");
		return modelAndView;
	}
	
	@ResponseBody
	@RequestMapping("/selectCompanyByCondition")
	public List<DefCompany> selectCompanyByCondition(DefCompany company) {
		return companyService.selectComByCondition(company);
	}
	
	/**
	 * 根据当前机构ID初始化机构级联下拉框<br>
	 * 返回参数说明：<br>
	 * grade：入参机构的级别<br>
	 * comList：与入参机构同级的机构列表<br>
	 * comMap：父级机构信息（map中的grade和comList同上）
	 * @param comId
	 * @return
	 */
	@ResponseBody
	@RequestMapping("/selectComById")
	public Map<String, Object> selectComById(Long comId) {
		return companyService.initUserModifyComSelect(comId);
	}
}
